package org.autoparser.exttree.attributes;

import org.htmlparser.NodeFilter;
import org.htmlparser.Tag;
import org.htmlparser.filters.HasAttributeFilter;

public class ZExtAttribute {
	private String attName;
	private String attValue;
	public ZExtAttribute(){
	}
	public ZExtAttribute(final String attName){
		this.attName = attName;
	}
	public ZExtAttribute(final String attName,final String attValue){
		this.attName = attName;
		this.attValue = attValue;
	}
	public boolean isAttSatisfy(Tag tag){
		return isAttSatisfy(tag,false);
	}
	public boolean isAttSatisfy(Tag tag,boolean caseSensitive){
		String aName = tag.getAttribute(attName);
		if(aName == null)
			return false;
		else
			return caseSensitive ? aName.compareTo(attValue)==0 : aName.compareToIgnoreCase(attValue)==0;
	}
	public NodeFilter getFilter(){
		return new HasAttributeFilter(attName,attValue);
	}
	public String getAttName() {
		return attName;
	}
	public void setAttName(String attName) {
		this.attName = attName;
	}
	public String getAttValue() {
		return attValue;
	}
	public void setAttValue(String attValue) {
		this.attValue = attValue;
	}
	
}
